<?php
// +----------------------------------------------------------------------
// | HomeLangBehavior.
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://www.abc3210.com, All rights reserved.
// +----------------------------------------------------------------------
// | Author: wjf <admin@abc3210.com> 2017/6/26
// +----------------------------------------------------------------------

namespace wjf\behavior;

use think\Lang;
use think\Request;

class HomeLangBehavior
{
    //行为扩展的执行入口文件必须run
    public function run()
    {
        $request = Request::instance();
        $langSet = $request->langset();

        //加载应用前台通用语言包
        $apps = wjf_scan_dir(APP_PATH . '*', GLOB_ONLYDIR);

        foreach ($apps as $app) {
            Lang::load([
                APP_PATH . $app . DS . 'lang' . DS . $langSet . DS . 'home' . EXT,
            ]);
        }
    }
}